<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑订阅</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://pic2.58.com/n/tuan/js/jquery-1.4.2.min.js"></script>
</head>
<body>
<div class="lr_both">
<div class="right_conts">
  <div class="mg_tt">
    <div class="right_search">
      <div class="rs_title_bg">
        <h2 class="rs_title">修改订阅</h2>
      </div>
	  
    </div>
	</br>
	</br>
	<form id="searchUser" name="searchUser" action="/submailmanager/show" method="post">
		
    </form>
    <div class="table_div" align="center">
      <table class="sj_tl sj_tl_2"  width="70%" border="0" cellspacing="0" cellpadding="0">
		<tr>
          <th align="center" colspan="2">订阅信息</th>
		</tr>
		<input type="hidden"  name="id" id="id" value="$vo.id"/>
        <tr>
           <td align="center" >订阅别名</td>
          <td align="center"  ><input type="text" style="width:300px" name="subName" id="subName" value="$!{vo.subName}"></input></td>
		
        </tr>
		  <tr>
			<td align="center" >发送频率</td>
			<td align="center" >
				<input type="radio" name="sendFreDay" id="sendFreDay" onclick="sendFre('1')"/>每日&nbsp;&nbsp;
				<input type="radio" name="sendFreWeek" id="sendFreWeek" onclick="sendFre('2')"/>每周&nbsp;&nbsp;
				<input type="hidden"  id="freValue" name ="freValue" value="$!{vo.sendFre}"/>
			</td>
        </tr>
		  <tr>
           <td align="center">收件人邮箱（可多个，以/号隔开，只可为公司邮箱）</td>
		  <td align="center" ><input type="text"  style="width:300px" name="sendEmail" id="sendEmail" value="$!{vo.sendEmail}"></input></td>
        </tr>
	 </table>
		</br>
	  
	  <table class="sj_tl sj_tl_2"  width="70%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
          <th align="center" colspan="2">
            <input type="button"  id="updateedit" name="updateedit"  value="保存"/>
		  </th>
		</tr>
      </table>
    </div>
  </div>
<script>
	function sendFre(id){
		$("#sendFreDay").attr("checked",false);
		$("#sendFreWeek").attr("checked",false);
		
		var value = "";
		
    	if(id == 1){
			value = "day";
			$("#sendFreDay").attr("checked",true);
		}else if(id == 2){
			value = "week";
			$("#sendFreWeek").attr("checked",true);
		}
		$("#freValue").val(value);
    }
	
	function checkFre(){
		var sendFre = $("#freValue").val();
		if(sendFre == "day"){
			$("#sendFreDay").attr("checked",true);
		}else if(sendFre == "week"){
			$("#sendFreWeek").attr("checked",true);
		}
		
	}
	checkFre();
	
	
	
	
$(function(){
   $("#updateedit").click(function(){
 	  var freValue = $("#freValue").val();
	  if("" == freValue){
	  	alert("请选择发送频率!");
		return false;
	  }
	  
	  var sendEmail = $("#sendEmail").val()
   	  if("" == sendEmail){
   	  	alert("订阅地址不能为空");
   	  	return false;
   	  }else{
   	  	var adsp = sendEmail.split('/');
   	  	for(var i=0;i<adsp.length;i++){
   	  		if(!(adsp[i].indexOf('@58.com') != -1||adsp[i].indexOf('@58ganji.com') != -1||adsp[i].indexOf('@zhiyou.ganji.com') != -1||adsp[i].indexOf('@ganji.com') != -1||adsp[i].indexOf('@doumi.com') != -1)){
   	  			alert("邮箱只可为公司企业邮箱");
   	  			return false;
   	  		}
   	  	}
   	  }
	  
      if(freValue != "" && sendEmail != ""){
      	jQuery.ajax({
            type:"POST",
            async:true,
            url:"/submailmanager/updateedit",
            data:{"sendEmail":$("#sendEmail").val(),"sendFre":freValue,"subName":$("#subName").val(),"id":$("#id").val()},
            success:function(data){
               if(data == "success"){
			   		alert("修改成功！");
					document.searchUser.submit();
			   }else{
			 		alert("修改失败！");
			   }
            }
       	 });
	  }
    });
});
	
</script>
</div>
</div>
</body>
</html>
